package com.atguigu.edu.realtime.publisher.mapper;

import com.atguigu.edu.realtime.publisher.bean.TrafficVideoPlayCount;
import com.atguigu.edu.realtime.publisher.bean.TrafficVideoPlayPersonCount;
import com.atguigu.edu.realtime.publisher.bean.TrafficVideoPlayTimeSum;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TrafficVideoPlayMapper {
    @Select("select\n" +
            "    chapterName,\n" +
            "    sum(videoplayedcount) pl_ct\n" +
            "from dws_traffic_video_play_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "group by toYYYYMMDD(stt), chapterName\n" +
            "order by pl_ct desc;")
    List<TrafficVideoPlayCount> selectPlCt(@Param("date") Integer date);

    @Select("select\n" +
            "    chapterName,\n" +
            "    sum(playedtimesum) tm_sum\n" +
            "from dws_traffic_video_play_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "group by toYYYYMMDD(stt),chapterName\n" +
            "order by tm_sum desc;")
    List<TrafficVideoPlayTimeSum> selectTmSum(@Param("date") Integer date);

    @Select("select\n" +
            "    chapterName,\n" +
            "    sum(personwatchedcount) wt_ct\n" +
            "from dws_traffic_video_play_window\n" +
            "where toYYYYMMDD(stt) = #{date}\n" +
            "group by toYYYYMMDD(stt),chapterName\n" +
            "order by wt_ct desc;")
    List<TrafficVideoPlayPersonCount> selectWtCt(@Param("date") Integer date);
}

